<%@page import="java.util.List"%>
<%@page import="kr.co.infovil.zipcode.service.StringMisc"%>
<%@page import="kr.co.infovil.zipcode.entity.ZipcodeDTO"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html;  charset=UTF-8"
	pageEncoding="UTF-8"%>

<%
	String dong = StringMisc.fixNull(request.getParameter("dong"));
	List<ZipcodeDTO> list = (List<ZipcodeDTO>) request.getAttribute("list");
%>


<table width="100%" cellspacing="0" cellpadding="0">
	<tr>
		<td>
			<table cellspacing="0" cellpadding="0">

				<tr>
					<td>

						<FORM name="ZipcodeSearchForm" action="/zipcode/dong_search.do" method="post">
							<table width="100%" cellspacing="0" cellpadding="0">
								<tr>
									<td class="td_default" width="100" align="right">검색어:&nbsp;</td>
									<td class="td_gray"><input class="input_default"
										type="text" name="dong" value="<%=dong%>">&nbsp;동(읍/면/리)&nbsp;
									</td>
									<td class="td_default">[<a class="a_default"
										href="javascript:window.document.ZipcodeSearchForm.submit();">검색</a>]
									</td>
								</tr>
							</table>
						</FORM>
					</td>
				</tr>

			</table>
		</td>
	</tr>



	<tr>
		<td height="5"></td>
	</tr>

	<tr>
		<td>
			<table cellspacing="0" cellpadding="0">

				<tr>
					<td>
						<table width="100%" cellspacing="0" cellpadding="0">
							<tr>
								<td class="td_default" width="100" align="right"></td>
								<td class="td_gray">예)&nbsp;신사1동 검색 : '신사1' 또는 '신사1동' 입력</td>
							</tr>
						</table>
					</td>
				</tr>

			</table>
		</td>
	</tr>

	<tr>
		<td height="5"></td>
	</tr>
	<tr>
		<td class="line_default" height="1"></td>
	</tr>
	<tr>
		<td height="5"></td>
	</tr>

	<%
		if (list != null && list.size() > 0) {
	%>

	<tr>
		<td>
			<table width="100%" cellspacing="0" cellpadding="0">

				<tr>
					<td>
						<table width="100%" cellspacing="0" cellpadding="0">
							<tr>
								<td class="td_default" width="100" align="center">우편번호</td>
								<td class="td_default">주&nbsp;&nbsp;&nbsp;소</td>
							</tr>
						</table>
					</td>
				</tr>

			</table>
		</td>
	</tr>

	<tr>
		<td height="5"></td>
	</tr>
	<tr>
		<td class="line_default" height="1"></td>
	</tr>
	<tr>
		<td height="5"></td>
	</tr>

	<%
			String zipcode = null;
			String showAddress = null;
			String passAddress = null;

			for (ZipcodeDTO dto : list) {
				
				
				 zipcode = dto.getZipcode();

		           showAddress = dto.getSido() + " " + dto.getGugun() + " " + dto.getDong();

		           if ( StringMisc.isAvailable( dto.getRi() ) )
		               showAddress += " " + StringMisc.fixNull( dto.getRi() );

		           passAddress = showAddress;

		           if ( StringMisc.isAvailable( dto.getBunji() ) )
		               showAddress += " " + StringMisc.fixNull( dto.getBunji() );
	%>

	<tr>
		<td>
			<table width="100%" cellspacing="0" cellpadding="0">

				<tr>
					<td>
						<table width="100%" cellspacing="0" cellpadding="0">
							<tr>
								<td class="td_default" width="100" align="center"><%=zipcode%></td>
                                <td class="td_default"><a class="a_default" href="javascript:ConfirmAddressSearch( '<%=zipcode%>', '<%=passAddress%>' );"><%=showAddress%></a></td>
							</tr>
						</table>
					</td>
				</tr>

			</table>
		</td>
	</tr>

	<tr>
		<td height="2"></td>
	</tr>

	<%
		} // end for

		} // end if
	%>

	<tr>
		<td height="5"></td>
	</tr>
	<tr>
		<td class="line_default" height="1"></td>
	</tr>
	<tr>
		<td height="5"></td>
	</tr>

	<tr>
		<td height="100%"></td>
	</tr>

</table>